#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
using LL = double;
const int N = 1e5 + 7;
LL v[N], a[N], pd[N];
bool overspeed[N];
int p[N], d[N];
LL deltea_s1(LL v_0, LL a, LL t) {
	return v_0 * t + 0.5 * a * t * t;
}
LL moment_v(LL v_0, LL a, LL s) {
	return sqrt(v_0*v_0 + 2 * a * s);
} 
LL deltea_s2(LL v_0, LL v_1, LL a) {
	return (v_1*v_1-v_0*v_0) / 2 * a;
}
int main() {
	freopen("detect.in", "r", stdin);
	freopen("detect.out", "w", stdout);
	int T;
	cin >> T;
	while (T--) {
		int n, m, L, V, tot = 0, canoff = 0;
		cin >> n >> m >> L >> V;
		for (int i = 1; i <= n; ++i)
			cin >> d[i] >> v[i] >> a[i];
		for (int i = 1; i <= m; ++i)
			cin >> p[i];
		for (int i = 1; i <= n; ++i) {
			for (int j = 1; j <= m; ++j) {
				if (p[j] < d[i] && moment_v(v[i], a[i], p[j]-d[i]) <= 0) continue;
				if (moment_v(v[i], a[i], p[j]-d[i]) > V) {
					overspeed[i] = true;
					++pd[j];
				}
			}
		}
		for (int i = 1; i <= n; ++i)
			if (overspeed[i]) ++tot;
		for (int i = 1; i <= m; ++i)
			if (pd[i] > 1) ++canoff;
		cout << tot << " " << canoff << '\n';
	} 
}
